package com.haiqi.common.utils;

/**
 * Created by Administrator on 2017/8/14 0014.
 */
public class LonLatUtils {

        public  static  String  changeLon(double d){
            String direction;
            if(d>=0)
            {
                if(d%360<=180)
                {
                    direction="E";
                }else {
                    d=360-d%360;
                    direction="W";
                }
            }else {
                if(d%360>=-180)
                {
                    d=Math.abs(d%360);
                    direction="W";
                }else {
                    d=d%360+360;
                    direction="E";
                }
            }
            int du=(int)d;
            int fen=(int)Math.floor((d-du)*60);
            double miao=((d-du)*60-fen)*60;
        return du+"°"+fen+"′"+((int)(miao*100))/100+"″"+direction;
         }



        public  static  String  changeLat(double d){
            String direction;
            if(d>=0)
            {
                direction="N";
            }else {
                d=Math.abs(d);
                direction="S";
            }
            int du=(int)d;
            int fen=(int)Math.floor((d-du)*60);
            double miao=((d-du)*60-fen)*60;
            return du+"°"+fen+"′"+((int)(miao*100))/100+"″"+direction;
        }


}
